// 页面路径：store/index.js
import Vuex from 'vuex'
import Vue from 'vue';
Vue.use(Vuex);//vue的插件机制
const store = new Vuex.Store({
	state:{//存放状态
		count:0
	},
	mutations:{
		addCount(state,payload){
			state.count+=payload
		}
	},
	actions:{
		addCountAsync({commit},payload){
			setTimeout(()=>{
				commit('addCount',payload)	
			},2000)
		
		}
	},
	getters:{
		doubleCount(state){
			return state.count*2
		}
	}
})
export default store